
<%@ page contentType="text/html;charset=UTF-8" %>
<%//@include file="../../common/sessionValidate.jsp" %>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<!DOCTYPE HTML>
<html lang="UTF-8">
<head>
    <title>申请信息</title>
    <%@ include file="../../common/meta.jsp" %>
    <script type="text/javascript" src="<%= basePath %>js/jquery-1.8.3.min.js"></script>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta http-equiv="X-UA-Compatible" content="IE=9">
    <META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
    <link rel="stylesheet" href="<%=basePath%>css/my-bootstrap.css" media="screen" id="tuserskin">
    <link rel="stylesheet" href="<%=basePath%>js/toastr/toastr.css">
    <link rel="stylesheet" href="<%=basePath%>css/bootstrapValidator.min.css">
    <link rel="stylesheet" href="<%=basePath%>css/font-awesome.min.css">
    <link rel="stylesheet" href="<%=basePath%>font-awesome-4.7.0/css/font-awesome.min.css">
    <!-- kind富文本编辑器  start-->
    <link rel="stylesheet" href="<%= basePath %>kindeditor/themes/default/default.css"/>
    <link rel="stylesheet" href="<%= basePath %>kindeditor/plugins/code/prettify.css"/>
    <script charset="utf-8" src="<%= basePath %>kindeditor/kindeditor.js"></script>
    <script charset="utf-8" src="<%= basePath %>kindeditor/lang/zh-CN.js"></script>
    <script charset="utf-8" src="<%= basePath %>kindeditor/plugins/code/prettify.js"></script>
    <!-- kind富文本编辑器  end-->

    <script type="text/javascript" src="<%= basePath %>js/jquery.cookie.js"></script>
</head>
<style>
    hr {
        margin-top: 1px;
        border-bottom: 1px solid #1BBC9B;
    }
</style>
<body>
<div class="" style="margin-right:2px;padding-right:1px;">
    <form class="form-horizontal form-bordered form-row-strippe" name="ffAdd" id="ffAdd" mentod="post" role="form"
          data-toggle="validator" enctype="multipart/form-data">

        <!-------------------------- 面板  start--------------------------------->
        <div class="panel panel-primary">
            <div class="panel-heading">
                <i class="icon-filter"></i>&nbsp;会议室预定
            </div>
            <div class="panel-body">
                <div class="row">

                    <div class="col-xs-12">

                        <div class="col-xs-5">
                            <div class="form-group">
                                <label class="control-label col-xs-2"><font color="red">*</font> 日期</label>
                                <div class="col-xs-10">
                                    <input id="ext1" name="ext1" type="text" class="form-control"
                                           placeholder="请选择日期" onclick='SelectDate(this)' onchange=""
                                           readonly='true'/>
                                    <input id="status" name="status" type="hidden" value="1"/>
                                    <input id="id" name="id" type="hidden"/>
                                    <input id="biztype" name="biztype" type="hidden" value="Meeting"/>
                                    <input id="level1name" name="level1name" type="hidden" value="会议室预定"/>
                                    <input id="types" name="types" type="hidden" value="Meeting"/>
                                    <input id="ext2" name="ext2" type="hidden" value=""/>
                                    <input id="ext3" name="ext3" type="hidden" value=""/>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-5">
                            <div class="form-group">
                                <label class="control-label col-xs-2"><font color="red">*</font>会议室</label>
                                <div class="col-xs-10">
                                    <select id="newfrom" name="newfrom" onchange="initHourList()" class="form-control">
                                        <option value="" selected>--请选择要预定会议室--</option>
                                        <option value="会议室1">会议室1</option>
                                        <option value="会议室2">会议室2</option>
                                        <option value="会议室3">会议室3</option>
                                        <option value="会议室4">会议室4</option>
                                        <option value="会议室5">会议室5</option>
                                        <option value="展厅">展厅</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                        <div class="col-xs-2">
                            <div class="form-group">
                                <div class="col-xs-10">
                                    <a href="#" style="vertical-align: center;" onclick="initHourList()"><span class="label label-success"><i class="icon-search"></i>查询会议室预定情况</span> </a>
                                </div>
                            </div>
                        </div>

                    </div><!--end 换列--><!--start 换列-->
                </div>
            </div>
            <!--------------------------面板 end------------------------------------>

            <!--------------------------查询条件表格  start------------------------------->

            <!-- 查询面板 -->
            <div class="panel panel-primary">
                <!-- Default panel contents -->

                <div class="row" style="padding:0 20px;">
                    <table class="table table-bordered table-striped" cellpadding="0" cellspacing="0">
                        <thead>
                        <tr class="">
                            <th>9:00-9:30</th>
                            <th>9:30-10:00</th>
                            <th>10:00-10:30</th>
                            <th>10:30-11:00</th>
                            <th>11:00-11:30</th>
                            <th>11:30-12:00</th>
                            <th>12:00-12:30</th>
                            <th>12:30-13:00</th>
                            <th>13:00-13:30</th>
                            <th>13:30-14:00</th>
                            <th>14:00-14:30</th>
                            <th>14:30-15:00</th>
                            <th>15:00-15:30</th>
                            <th>15:30-16:00</th>
                            <th>16:00-16:30</th>
                            <th>16:30-17:00</th>
                            <th>17:00-17:30</th>
                            <th>17:30-18:00</th>
                        </tr>
                        </thead>
                        <tbody id="hourListDiv">
                        </tbody>
                    </table>
                </div>
            </div>

            <!--  <button id="" onclick="add4()">2121</button>-->

            <!-------------------------- 面板  start--------------------------------->
            <div class="panel panel-primary">
                <div class="panel-body">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"><font color="red">*</font> 会议主题</label>
                                    <div class="col-xs-10">
                                        <input id="title" name="title" class="form-control"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"> 参会人 </label>
                                    <div class="col-xs-10">
                                        <input id="ext7" name="ext7" type="text" value=""
                                               class="form-control" placeholder=""/>
                                    </div>
                                </div>
                            </div>
                        </div><!--end 换列--><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"><font color="red">*</font> 是否需要讲解人员</label>
                                    <div class="col-xs-10">
                                        <select id="ext4" name="ext4" class="form-control">
                                            <option value="是">是</option>
                                            <option value="否" selected>否</option>
                                        </select>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"> 参会人数 </label>
                                    <div class="col-xs-10">
                                        <input id="ext5" name="ext5" type="text" value=""
                                               class="form-control" placeholder=""/>
                                    </div>
                                </div>
                            </div>
                        </div><!--end 换列--><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"><font color="red">*</font>申请人</label>
                                    <div class="col-xs-10">
                                        <input id="creater" name="creater" type="text"
                                               value="<%=request.getSession().getAttribute("FREE_CURRENT_USER") %>"
                                               class="form-control" placeholder="" readonly="true"/>
                                    </div>
                                </div>
                            </div>
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"><font color="red">*</font>申请时间</label>
                                    <div class="col-xs-10">
                                        <input id="creattime" name="creattime" type="text" class="form-control"
                                               placeholder="" readonly="true"/>
                                    </div>
                                </div>
                            </div>

                        </div><!--end 换列--><!--start 换列-->
                        <div class="col-xs-12">
                            <div class="col-xs-6">
                                <div class="form-group">
                                    <label class="control-label col-xs-2"> 备注</label>
                                    <div class="col-xs-10">
                                        <textarea id="ext6" name="ext6" class="form-control" cols="3" ></textarea>
                                    </div>
                                </div>
                            </div>
                        </div><!--end 换列--><!--start 换列-->

                    </div><!--end body-->
                    <div class="modal-footer bg-info " id='buttonDiv'>
                    </div>
                </div>
            </div>
            <!--------------------------面板 end------------------------------------>

        </div>
    </form>

    <!-- 模态框（Modal）start -->
    <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
         aria-hidden="true">
        <div class="modal-dialog">
            <div class="modal-content">
                <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                    <h4 class="modal-title" id="myModalLabel">提示</h4>
                </div>
                <div class="modal-body" id="myModalMessDiv"></div>
                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                </div>
            </div><!-- /.modal-content -->
        </div><!-- /.modal -->
    </div>
    <!-- 模态框（Modal）end -->

</body>
</html>
<script src="<%=basePath%>js/bootstrap.min.js"></script>
<script src="<%=basePath%>js/bootstrap-paginator.min.js"></script>
<script src="<%=basePath%>/js/respond.js"></script>
<script src="<%=basePath%>/js/html5.js"></script>
<script src="<%=basePath%>js/toastr/toastr.js"></script>
<script src="<%=basePath%>js/bootbox.js"></script>
<script src="<%=basePath%>js/jquery.validate.js"></script>
<script src="<%=basePath%>js/my-jquery-curd.js"></script>
<script src="<%=basePath%>js/tableSortTool.js"></script>
<script src="<%=basePath%>js/calendar.js"></script>
<script type="text/javascript">
    function add4() {
        var id = "";
        var time = "";
        $(".btn-danger").each(function (i, e) {
            //tags[i]= $(this).context.innerText;
            id += $(this).attr("data-id") + ";";
            time += $(this).attr("data-time") + ";";
            //console.log(e);
        });

        alert("id=" + id + ";time=" + time);
        // 初始化不输出 id，既可以实现 不能选的效果；
        //<td><button type="button" class="btn btn-sm btn-danger" data-id="3" data-time="9:00-9:30" data-flag="1">满</button></td>
        //初始化输出 id，既可以实现 能选的效果；
        //<td><button type="button" class="btn btn-sm btn-primary" data-id="3" data-time="9:30-10:00" data-flag="0" id="yuding">空</button></td>

    }

    //新增保存数据
    function add() {
        //var id = "";  //会议室id
        var time = ""; //会议室预定时间
        $(".btn-danger").each(function (i, e) {
            //tags[i]= $(this).context.innerText;
            //id += $(this).attr("data-id") + ";";
            time += $(this).attr("data-time") + ";";
            //console.log(e);
        });
        //alert("time=" + time);
        //$("#ext2").val(time);
        //加工本次选中的值，去除从后台加载的其它人预定的值；
        var ext3 = document.getElementById("ext3").value;
        //alert("time="+time+";ext3="+ext3)
        var ext2 = "";
        var temp = time.split(";")
        for(var i=0; i<temp.length; i++){
            //如果当前页面中全部选中的时间段值中有老的值；则说明是其它申请预定了该时间段，所以去掉已经预定的重复的值；
            if(ext3.indexOf(temp[i])!=-1){ //老的包含 temp[i];则去掉；
                //alert("老的包含"+temp[i]);
                time = time.replace(temp[i]+';',''); //去掉已经预定的重复的时间段；
                //alert("去掉"+temp[i]+"后的time="+time)
            }
        }
        time = time.replace('undefined;',''); //去掉不合法的值； /123/g全部替换，否则只替换第一个；
        time = time.replace(";;",';'); //去掉多余的分号； /123/g全部替换，否则只替换第一个；
        //alert("time="+time);
        //赋值给ext2，传输到后台保存本次预定的值；
        document.getElementById("ext2").value= time ;

        $("#addSaveButton").attr("disabled", true);
        var url = "<%=basePath%>t_news/saveT_news?time=" + Math.random();
        var postData = $("#ffAdd").serializeArray();
        $.post(url, postData, function (data) {
            if (data.result == "success") {
                showSuccessTips("恭喜保存成功!", "提示");  //保存成功  1.关闭弹出层，
            } else {
                $("#addSaveButton").removeAttr("disabled");
                $("#myModal").modal('show'); //hide;
                $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
                return false;
            }
        }).error(function () {
            $("#addSaveButton").removeAttr("disabled");
            //showErrorTips("保存数据失败!", "错误信息：");
            $("#myModal").modal('show'); //hide;
            $("#myModalMessDiv").html("<font color='red'>对不起,保存数据失败，失败原因：" + data.info + "</font>");
        });
    }

    //更新修改数据到后台
    function edit() {
        $("#editSaveButton").attr("disabled", true);
        var url = "<%=basePath%>t_news/updateT_news?time=" + Math.random();
        myEdit2(url);
    }

    //更新修改数据到后台并且启动工作流
    function tjsh() {
        $("#editSaveButton").attr("disabled", true);
        $("#tjshSaveButton").attr("disabled", true);
        var url = "<%=basePath%>t_news/tjshT_news?time=" + Math.random();
        myCurdTjsh(url);
    }

    //初始化数据档案类型下拉框；
    function initDataGroup() {
        var purl = "<%=basePath%>t_data_dic/getAllT_data_dic?data_group=danganguanli&flag=1&startIndex=0&pageSize=1000&time=" + Math.random();
        $.getJSON(purl, function (data) {
            var optionHtml = "";
            $.each(data.items, function (i, item) {
                optionHtml += "<option value='" + item.data_no + "'>" + item.data_name + "</option>";
            });//end each
            $("#types").append(optionHtml);
        }); //end getJson
    }

    //查看和修改（不放开修改，只能删除重新新增）时，只显示该申请对应的预定时间；
    function initHourListSelf(hour){
        var str = '<tr>';
        // 初始化不输出 id，既可以实现 不能选的效果
        //初始化输出 id，既可以实现 能选的效果；
        if (hour.indexOf("9:00-9:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="9:00-9:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="9:00-9:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("9:30-10:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="9:30-10:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="9:30-10:00" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("10:00-10:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="10:00-10:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="10:00-10:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("10:30-11:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="10:30-11:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="10:30-11:00" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("11:00-11:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time=11:00-11:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="11:00-11:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("11:30-12:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="11:30-12:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="11:30-12:00" data-flag="0"  >未选</button></td>';
        }
        //12点到3点
        if (hour.indexOf("12:00-12:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="12:00-12:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="12:00-12:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("12:30-13:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="12:30-13:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="12:30-13:00" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("13:00-13:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="13:00-13:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="13:00-13:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("13:30-14:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="13:30-14:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="13:30-14:00" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("14:00-14:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="14:00-14:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="14:00-14:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("14:30-15:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="14:30-15:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="14:30-15:00" data-flag="0"  >未选</button></td>';
        }

        //3点到6点
        if (hour.indexOf("15:00-15:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="15:00-15:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="15:00-15:30" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("15:30-16:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="15:30-16:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="15:30-16:00" data-flag="0"  >未选</button></td>';
        }
        if (hour.indexOf("16:00-16:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="16:00-16:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="16:00-16:30" data-flag="0" >未选</button></td>';
        }
        if (hour.indexOf("16:30-17:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="16:30-17:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="16:30-17:00" data-flag="0" >未选</button></td>';
        }
        if (hour.indexOf("17:00-17:30") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="17:00-17:30" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="17:00-17:30" data-flag="0">未选</button></td>';
        }
        if (hour.indexOf("17:30-18:00") >= 0) {
            str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="17:30-18:00" data-flag="0" >满</button></td>';
        } else {
            str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="17:30-18:00" data-flag="0" >未选</button></td>';
        }

        str += '</tr>';
        $("#hourListDiv").append(str);
    }

    //查询 会议室目前预定时间，并且在页面上显示可预定时间；
    function initHourList() {
        var ext1 = document.getElementById("ext1").value;  //时间
        var newfrom = document.getElementById("newfrom").value;  //会议室
        if(ext1==null||ext1==""){
            alert("请选择时间！");
            return ;
        }else if(newfrom==null||newfrom==""){
            alert("请选择要预定的会议室！");
            return;
        }else{
            //alert("99999999999");
            var url = "<%=basePath%>t_news/getAllT_news?startIndex=0&pageSize=1000&newfrom=" + newfrom + "&ext1=" + ext1 + "&time=" + Math.random();
            //alert(url);
            $.getJSON(url, function (data) {
                $("#hourListDiv").html("");
                //1、表格行内容输出
                var hour = "";
                $.each(data.items, function (i, item) {
                    hour += item.ext2 + ";";
                });//end each data;
                //alert("hour="+hour);
                document.getElementById("ext3").value = hour; //设置old值，非本人的；
                var str = '<tr>';
                // 初始化不输出 id，既可以实现 不能选的效果
                //初始化输出 id，既可以实现 能选的效果；
                if (hour.indexOf("9:00-9:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="9:00-9:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="9:00-9:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("9:30-10:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="9:30-10:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="9:30-10:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("10:00-10:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="10:00-10:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="10:00-10:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("10:30-11:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="10:30-11:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="10:30-11:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("11:00-11:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time=11:00-11:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="11:00-11:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("11:30-12:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="11:30-12:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="11:30-12:00" data-flag="0" id="yuding">空</button></td>';
                }
                //12点到3点
                if (hour.indexOf("12:00-12:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="12:00-12:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="12:00-12:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("12:30-13:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="12:30-13:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="12:30-13:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("13:00-13:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="13:00-13:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="13:00-13:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("13:30-14:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="13:30-14:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="13:30-14:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("14:00-14:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="14:00-14:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="14:00-14:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("14:30-15:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="14:30-15:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="14:30-15:00" data-flag="0" id="yuding">空</button></td>';
                }

                //3点到6点
                if (hour.indexOf("15:00-15:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="15:00-15:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="15:00-15:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("15:30-16:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="15:30-16:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="15:30-16:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("16:00-16:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="16:00-16:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="16:00-16:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("16:30-17:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="16:30-17:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="16:30-17:00" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("17:00-17:30") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="17:00-17:30" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="17:00-17:30" data-flag="0" id="yuding">空</button></td>';
                }
                if (hour.indexOf("17:30-18:00") >= 0) {
                    str += '<td><button type="button" class="btn btn-sm btn-danger" data-id="1" data-time="17:30-18:00" data-flag="0" >满</button></td>';
                } else {
                    str += '<td><button type="button" class="btn btn-sm btn-primary" data-id="1" data-time="17:30-18:00" data-flag="0" id="yuding">空</button></td>';
                }

                str += '</tr>';
                $("#hourListDiv").append(str);
            })//end getJSON;
        } //end else;
    }

    //初始化页面及校验
    $().ready(function () {
        //1、初始化数据显示
        var optype = '<%=request.getParameter("oplx")%>';
        var id = '<%=request.getParameter("id")%>';
        var functname = "会议室预定";//'<%=request.getParameter("functname")%>';
        var functid = '<%=request.getParameter("functid")%>';
        var name = functname; //"新闻";

        if (optype == 'add') {
            $("#ffAdd")[0].reset();/*重置表单*/
            var basePath = "<i class='icon-plus'></i>&nbsp;";
            setHeader2("添加" + functname, basePath);//设置addHeaderDiv标题文字及按钮
            setButtonDivAdd2();//设置底部adddiv的 操作按钮
            initTime("ext1", "2");
            initTime("creattime", "1");
            //initDataGroup();
        } else if (optype == 'edit') {
            var basePath = "<i class='icon-pencil'></i>&nbsp;";
            setHeader2("修改" + functname, basePath);//设置addHeaderDiv标题文字及按钮
            setButtonDivEdit2();//设置adddiv的 操作按钮
            //initDataGroup();
            var url = "<%=basePath%>t_news/getT_news?id=" + id + "&time=" + Math.random();
            $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
                setValue(data);
                initHourListSelf(data.ext2);
                //$("#effect_date").val(jsonDateFormat($("#effect_date").val())); //重新设置日期类型的值
            });

        } else if (optype == 'view') {
            var basePath = "<i class='icon-eye-open'></i>&nbsp;";//设置addHeaderDiv标题文字及按钮
            setHeader2("查看" + functname, basePath);
            setButtonDivView2();//设置adddiv的 操作按钮
            //initDataGroup();
            var url = "<%=basePath%>t_news/getT_news?id=" + id + "&time=" + Math.random();
            $.getJSON(url, function (data) {//获取数据，并且自动填充form，自动代码待修改； @todo;
                setValue(data);
                initHourListSelf(data.ext2);
            });
            formReadOnly('ffAdd');//设置表单不可修改
        }

        //2、校验脚本初始化，start check
        $("#ffAdd").validate({
            submitHandler: function (form) {
                if ($("#opType").val() == "add") {
                    add();
                } else if ($("#opType").val() == "edit") {
                    edit();
                }
            },
            rules: {
                id: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                extint1: {
                    required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 4
                },
                types: {
                    //required: true,
                    maxlength: 45
                },
                title: {
                    required: true,
                    maxlength: 256
                },
                creater: {
                    //required: true,
                    maxlength: 45
                },
                updater: {
                    //required: true,
                    maxlength: 45
                },
                publisher: {
                    //required: true,
                    maxlength: 45
                },
                creattime: {
                    //required: true,
                    maxlength: 45
                },
                updattime: {
                    //required: true,
                    maxlength: 45
                },
                publishtime: {
                    //required: true,
                    maxlength: 45
                },
                checker: {
                    //required: true,
                    maxlength: 45
                },
                checktime: {
                    //required: true,
                    maxlength: 45
                },
                hticount: {
                    //required: true,
                    maxlength: 45
                },
                color: {
                    //required: true,
                    maxlength: 45
                },
                size: {
                    //required: true,
                    maxlength: 45
                },
                zg: {
                    //required: true,
                    maxlength: 128
                },
                cq: {
                    //required: true,
                    maxlength: 512
                },
                content: {
                    required: true,
                    maxlength: 6000
                },
                memo: {
                    //required: true,
                    maxlength: 1024
                },
                ext1: {
                    required: true,
                    maxlength: 45
                },
                ext2: {
                    //required: true,
                    maxlength: 45
                },
                ext3: {
                    required: true,
                    maxlength: 45
                },
                ext4: {
                    required: true,
                    maxlength: 256
                },
                ext5: {
                    //required: true,
                    maxlength: 256
                },
                ext6: {
                    //required: true,
                    maxlength: 256
                },
                ext7: {
                    //required: true,
                    maxlength: 512
                },
                ext8: {
                    //required: true,
                    maxlength: 512
                },
                ext9: {
                    //required: true,
                    maxlength: 512
                },
                status: {
                    //required: true,
                    maxlength: 45
                },
                check2: {
                    //required: true,
                    maxlength: 45
                },
                classes: {
                    //required: true,
                    maxlength: 45
                },
                checkstatus: {
                    //required: true,
                    maxlength: 45
                },
                link: {
                    //required: true,
                    maxlength: 512
                },
                newdate: {
                    required: true,
                    maxlength: 45
                },
                newfrom: {
                    required: true,
                    maxlength: 45
                },
                descriptions: {
                    //required: true,
                    maxlength: 1024
                },
                level1: {
                    //required: true,
                    maxlength: 45
                },
                level2: {
                    //required: true,
                    maxlength: 45
                },
                level3: {
                    //required: true,
                    maxlength: 45
                },
                level1name: {
                    //required: true,
                    maxlength: 45
                },
                level2name: {
                    //required: true,
                    maxlength: 45
                },
                level3name: {
                    //required: true,
                    maxlength: 45
                },
                imagepath: {
                    //required: true,
                    maxlength: 512
                },
                shownum: {
                    //required: true,
                    digits: true,
                    //minlength: 1,
                    maxlength: 11
                },
                ranger: {
                    //required: true,
                    maxlength: 45
                }
            }, //end rules;
            messages: {
                id: {
                    //required: "主键不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>主键最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                extint1: {
                    required: "<font color='red'>请输入数字，不能输入非数字字符！</font>！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>主键最大支持4位，输入的数据已经超过最大长度！</font>"
                },
                types: {
                    maxlength: "<font color='red'>新闻类型最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                title: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                creater: {
                    maxlength: "<font color='red'>录入人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                extdouble1: {
                    //required: "显示顺序不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>显示顺序最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                updater: {
                    maxlength: "<font color='red'>更新人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                publisher: {
                    maxlength: "<font color='red'>发布人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                creattime: {
                    maxlength: "<font color='red'>录入时间最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                updattime: {
                    maxlength: "<font color='red'>更新时间最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                publishtime: {
                    maxlength: "<font color='red'>发布时间最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                checker: {
                    maxlength: "<font color='red'>审核人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                checktime: {
                    maxlength: "<font color='red'>审核时间最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                hticount: {
                    maxlength: "<font color='red'>点击率最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                color: {
                    maxlength: "<font color='red'>颜色最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                size: {
                    maxlength: "<font color='red'>标题字体最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                zg: {
                    maxlength: "<font color='red'>撰稿摄影最大支持128位,输入的数据已经超过最大长度！</font>"
                },
                cq: {
                    maxlength: "<font color='red'>错情最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                content: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'>最大支持6,000位,输入的数据已经超过最大长度！</font>"
                },
                memo: {
                    maxlength: "<font color='red'>备注最大支持1,024位,输入的数据已经超过最大长度！</font>"
                },
                ext1: {
                    required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                ext2: {
                    //required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                ext3: {
                    required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                ext4: {
                    required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 输入的数据已经超过最大长度！</font>"
                },
                ext5: {
                    //required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 输入的数据已经超过最大长度！</font>"
                },
                ext6: {
                    //required: "<font color='red'>  不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                ext7: {
                    //required: "<font color='red'>视频不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                ext8: {
                    maxlength: "<font color='red'> ext8最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                ext9: {
                    maxlength: "<font color='red'> ext9最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                status: {
                    maxlength: "<font color='red'>状态最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                check2: {
                    maxlength: "<font color='red'>复核人最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                classes: {
                    maxlength: "<font color='red'>扩展类型最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                checkstatus: {
                    maxlength: "<font color='red'>审核状态最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                link: {
                    maxlength: "<font color='red'>链接地址最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                newdate: {
                    required: "<font color='red'>请选择 开始日期！</font>",
                    maxlength: "<font color='red'>开始日期 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                newfrom: {
                    required: "<font color='red'> 不能为空！</font>",
                    maxlength: "<font color='red'> 最大支持20位,输入的数据已经超过最大长度！</font>"
                },
                descriptions: {
                    maxlength: "<font color='red'>说明最大支持1,024位,输入的数据已经超过最大长度！</font>"
                },
                level1: {
                    maxlength: "<font color='red'>栏目1级最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                level2: {
                    maxlength: "<font color='red'>栏目2级最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                level3: {
                    maxlength: "<font color='red'>栏目3级最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                level1name: {
                    maxlength: "<font color='red'> level1name最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                level2name: {
                    maxlength: "<font color='red'> level2name最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                level3name: {
                    maxlength: "<font color='red'> level3name最大支持45位,输入的数据已经超过最大长度！</font>"
                },
                imagepath: {
                    required: "<font color='red'>截图不能为空！</font>",
                    maxlength: "<font color='red'>截图最大支持512位,输入的数据已经超过最大长度！</font>"
                },
                shownum: {
                    //required: "显示顺序不能为空！",
                    digits: "<font color='red'>请输入数字，不能输入非数字字符！</font>",
                    //minlength: "<font color='red'>最少输入1位！</font>",
                    maxlength: "<font color='red'>显示顺序最大支持11位，输入的数据已经超过最大长度！</font>"
                },
                ranger: {
                    maxlength: "<font color='red'>范围最大支持45位,输入的数据已经超过最大长度！</font>"
                }
            } //end message;
        }); //end validate;
    }) //end funciton read;
</script>
<script type="text/javascript">
    //给今天赋值
    /*
    var Today = new Date();
    var obj = document.getElementById("CreateDate");
    var m = Today.getMonth() + 1;
    var d = Today.getDate();
    if (m < 10) {
        m = "0" + m;
    }
    if (d < 10) {
        d = "0" + d;
    }
    obj.value = Today.getFullYear() + "-" + m + "-" + d;

    //上一天

    function Previousday() {
        var today = new Date(document.getElementById("CreateDate").value);
        var yesterday_milliseconds = today.getTime() - 1000 * 60 * 60 * 24;

        var yesterday = new Date();
        yesterday.setTime(yesterday_milliseconds);

        var strYear = yesterday.getFullYear();

        var strDay = yesterday.getDate();
        var strMonth = yesterday.getMonth() + 1;

        if (strMonth < 10) {
            strMonth = "0" + strMonth;
        }
        if (strDay < 10) {
            strDay = "0" + strDay;
        }
        var strYesterday = strYear + "-" + strMonth + "-" + strDay;
        var obj = document.getElementById("CreateDate");
        obj.value = strYesterday;
    }

    //下一天
    function NextDay() {
        var today = new Date(document.getElementById("CreateDate").value);
        var yesterday_milliseconds = today.getTime() + 1000 * 60 * 60 * 24;

        var yesterday = new Date();
        yesterday.setTime(yesterday_milliseconds);

        var strYear = yesterday.getFullYear();

        var strDay = yesterday.getDate();
        var strMonth = yesterday.getMonth() + 1;

        if (strMonth < 10) {
            strMonth = "0" + strMonth;
        }
        if (strDay < 10) {
            strDay = "0" + strDay;
        }
        var strYesterday = strYear + "-" + strMonth + "-" + strDay;
        var obj = document.getElementById("CreateDate");
        obj.value = strYesterday;
    }
*/

</script>


<script type="text/javascript">
    $('body').on('click', '#yuding', function () {
        var id = $(this).attr("data-id");
        var time = $(this).attr("data-time");
        var flag = $(this).attr("data-flag");
        //var className=$(this).attr("class");
        // 入库
        if (flag == 0) {
            //$(this).setAttribute("class","btn-danger");
            $(this).removeClass("btn btn-sm btn-primary");
            $(this).addClass("btn btn-sm btn-danger");
            $(this).attr("data-flag", "1");
            $(this).html("满");

        } else {
            $(this).removeClass("btn btn-sm btn-danger");
            $(this).addClass("btn btn-sm btn-primary");
            $(this).attr("data-flag", "0");
            $(this).html("空");
        }
    });
</script>
